#ifdef _WIN32
#include "../../../Container/Map.h"
#include "LostResourceManager.h"
#include "LostResource.h"

using namespace Stray::Core::Graphics::DirectX9;

void LostResourceManagerImpl::initialize()
{
	hasInitialized_ = B_TRUE;
	hasTerminated_ = B_FALSE;
}

void LostResourceManagerImpl::terminate()
{
	hasTerminated_ = B_TRUE;
}

void LostResourceManagerImpl::addResource(LostResource* pResource)
{
	Stray::Pair<LostResourceSet::iterator, bool>::type result = resources_.insert(pResource);
	assert(result.second);
}

void LostResourceManagerImpl::removeResource(LostResource* pResource)
{
	if(hasTerminated_) return;
	LostResourceSet::iterator iter = resources_.find(pResource);
	if(iter != resources_.end()) resources_.erase(iter);
}

void LostResourceManagerImpl::releaseResource()
{
	LostResourceSet::iterator iter;
	for(iter = resources_.begin(); iter != resources_.end(); ++iter)
	{
		if((*iter) != 0) (*iter)->releaseResource();
	}
}

void LostResourceManagerImpl::recoverResource()
{
	LostResourceSet::iterator iter;
	for(iter = resources_.begin(); iter != resources_.end(); ++iter)
	{
		if((*iter) != 0) (*iter)->recoverResource();
	}
}

#endif